﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Api.Filter;
using Customer.Bussiness_Service;
using Entity;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using ServiceCore;


namespace Customer.Areas.crm_warehouse.Controllers
{
    [ApiController, Area("warehouse"), Route("/warehouse/[action]"), Customer_Admin]
    public class warehouseController : ControllerBase
    {
        private readonly Iwarehouse_base_service _service;
        private readonly IToole_DI _tool;
        public warehouseController(Iwarehouse_base_service service, IToole_DI tool)
        {
            _service = service;
            _tool = tool;
        }
        /// <summary>
        /// 保存仓库信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpGet]
        public ResultObjModel save(string base_id, string base_name, string parent_id = "0")
        {
            var result = _service.save_warehouse(base_id, base_name, parent_id);
            return result;
        }
        /// <summary>
        /// 获取仓库列表
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpGet]
        public ResultObjModel get_list(string parent_id = "0")
        {
            var result = _service.get_warehouse(parent_id);
            return result;
        }
        /// <summary>
        /// 设置仓库状态
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpGet]
        public ResultObjModel set_state(string base_id, warehouse_base_state? warehouse_base_state)
        {
            var result = _service.set_warehouse_state(base_id, warehouse_base_state);
            return result;
        }
        /// <summary>
        /// 获取仓库列表
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpGet]
        public ResultObjModel get_tree()
        {
            var result = _service.get_warehouse_tree();
            return result;
        }



        /// <summary>
        /// 保存库位设置信息
        /// </summary>
        /// <param name="Params"></param>
        /// <returns></returns>
        [HttpPost]
        public ResultObjModel save_warehouse_position(save_warehouse_position_params Params)
        {
            var result = _service.save_warehouse_position(Params);
            return result;
        }

        /// <summary>
        /// 设置库位物料
        /// </summary>
        /// <param name="Params"></param>
        /// <returns></returns>
        [HttpGet]
        public ResultObjModel set_warehouse_position_materiel(string warehouse_position_id, string materiel_id)
        {
            var result = _service.set_warehouse_position_materiel(warehouse_position_id, materiel_id);
            return result;
        }
        /// <summary>
        /// 设置库位物料状态
        /// </summary>
        /// <param name="Params"></param>
        /// <returns></returns>
        [HttpGet]
        public ResultObjModel set_warehouse_position_state(string warehouse_position_id, warehouse_position_state? warehouse_position_state)
        {
            var result = _service.set_warehouse_position_state(warehouse_position_id, warehouse_position_state);
            return result;
        }
        /// <summary>
        /// 库位列表查询
        /// </summary>
        /// <param name="Params"></param>
        /// <returns></returns>
        [HttpPost]
        public ResultListModel<search_warehouse_position_item> get_pagelist(search_warehouse_position_params query)
        {
            var result = _service.get_pagelist(query);
            return result;
        } 
    }
}